<template>
	<div class="main-1">
		<div class="input-list">
			<div class="input-item" v-for="(item, key) in text" :key="key" :style="'width: ' + (1 / textLength) * 100 + '%;'" :class="{
				on: cursor && (key >= text.length - 1),
				frame: isFrame
			}">
				{{ item }}
			</div>
		</div>
	</div>
</template>

<script>
export default {
	data() {
		return {
			text: ''
		}
	},
	props: {
		textLength: {
			type: Number,
			default: () => {
				return 7;
			}
		},
		inputText: {
			type: String,
			default: () => {
				return '';
			}
		},
		cursor: {
			type: Boolean,
			default: () => {
				return true;
			}
		},
		isFrame: {
			type: Boolean,
			default: () => {
				return false;
			}
		}
	},
	methods: {

	},
	mounted() {

	},
	watch: {
		inputText(val, oldVal) {
			if (val.length <= this.textLength) {
				this.text = val
			}
		}
	}
}
</script>

<style scoped lang="scss">
.main-1 {
	width: 100%;
	height: 120upx;
	box-sizing: border-box;
	border: 1px solid #ebebeb;
	.input-list {
		width: calc(100% + 2px);
		height: 120upx;
		display: flex;
		// justify-content: space-around;
		align-items: center;
		position: relative;
		left: -1px;
		top: -1px;
		.input-item {
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36upx;
			line-height: 1;
			color: #000;
			font-weight: bold;
			box-sizing: border-box;
		}
		.on {
			border: 1px solid #4ac8ff;
		}
		.frame {
			border-right: 1px solid #EBEBEB;
			&:last-child {
				border-right: none;
			}
		}
		.off {
			border: none;
		}
	}
}
</style>
